package com.spic.business.registrationform.controller;

import com.spic.business.registrationform.domain.ArchiveStaffPromotionRecord;
import com.spic.business.registrationform.service.IArchiveStaffPromotionRecordService;
import com.spic.common.core.utils.poi.ExcelUtil;
import com.spic.common.core.web.controller.BaseController;
import com.spic.common.core.web.domain.AjaxResult;
import com.spic.common.core.web.page.TableDataInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;


/**
 * 职称/技能等级晋升情况记录Controller
 * 
 * @author spic
 * @date 2022-07-20
 */
@RestController
@RequestMapping("/promotion/record")
public class ArchiveStaffPromotionRecordController extends BaseController
{
    @Autowired
    private IArchiveStaffPromotionRecordService archiveStaffPromotionRecordService;

    /**
     * 查询职称/技能等级晋升情况记录列表
     */
    @GetMapping("/list")
    public TableDataInfo list(ArchiveStaffPromotionRecord archiveStaffPromotionRecord)
    {
        startPage();
        List<ArchiveStaffPromotionRecord> list = archiveStaffPromotionRecordService.selectArchiveStaffPromotionRecordList(archiveStaffPromotionRecord);
        return getDataTable(list);
    }

    /**
     * 导出职称/技能等级晋升情况记录列表
     */
    @PostMapping("/export")
    public void export(HttpServletResponse response, ArchiveStaffPromotionRecord archiveStaffPromotionRecord) throws IOException {
        List<ArchiveStaffPromotionRecord> list = archiveStaffPromotionRecordService.selectArchiveStaffPromotionRecordList(archiveStaffPromotionRecord);
        ExcelUtil<ArchiveStaffPromotionRecord> util = new ExcelUtil<ArchiveStaffPromotionRecord>(ArchiveStaffPromotionRecord.class);
        util.exportExcel(response, list, "职称/技能等级晋升情况记录数据");
    }

    /**
     * 获取职称/技能等级晋升情况记录详细信息
     */
    @GetMapping(value = "/{promotionId}")
    public AjaxResult getInfo(@PathVariable("promotionId") Long promotionId)
    {
        return AjaxResult.success(archiveStaffPromotionRecordService.selectArchiveStaffPromotionRecordByPromotionId(promotionId));
    }

    /**
     * 新增职称/技能等级晋升情况记录
     */
    @PostMapping
    public AjaxResult add(@RequestBody ArchiveStaffPromotionRecord archiveStaffPromotionRecord)
    {
        return toAjax(archiveStaffPromotionRecordService.insertArchiveStaffPromotionRecord(archiveStaffPromotionRecord));
    }

    /**
     * 修改职称/技能等级晋升情况记录
     */
    @PutMapping
    public AjaxResult edit(@RequestBody ArchiveStaffPromotionRecord archiveStaffPromotionRecord)
    {
        return toAjax(archiveStaffPromotionRecordService.updateArchiveStaffPromotionRecord(archiveStaffPromotionRecord));
    }

    /**
     * 删除职称/技能等级晋升情况记录
     */
	@DeleteMapping("/{promotionIds}")
    public AjaxResult remove(@PathVariable Long[] promotionIds)
    {
        return toAjax(archiveStaffPromotionRecordService.deleteArchiveStaffPromotionRecordByPromotionIds(promotionIds));
    }
}
